package com.sample.action;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.sample.action.form.BkaoqinForm;
import com.sample.javabean.Bkaoqin;
import com.sample.util.Pager;

     /**
     * @author梁桂花
     *
     * 2018-10-24
     */
           public class BkaoqinAction extends BaseAction {
    	 
      
    	   private final static Log log=LogFactory.getLog(BkaoqinAction.class);
    	 	private Pager<Bkaoqin> pageList;
    	 	private Integer id;
    	 	private Bkaoqin bkaoqin=new Bkaoqin();
    	 	private BkaoqinForm bkaoqinForm=new BkaoqinForm();
    	 	
    	 	
    	 	/**
    	 	 * 幼儿信息录入界面
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String inputBkaoqin()throws Exception{
    	 		
    	 		return "inputBkaoqin";
    	 	}
    	 	/**
    	 	 * 
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String save()throws Exception{
    	 		try{
    	 			log.info("添加考勤信息");
    	 			if(bkaoqinForm!=null){
    	 				Bkaoqin bkaoqin =new Bkaoqin();
    	 				 //将bkaoqinForm中的属性值一一对应bkaoqin的对应属性
    	 				bkaoqin.setBname(bkaoqinForm.getBname());
    	 				bkaoqin.setChuqin(bkaoqinForm.getChuqin());
    	 				bkaoqin.setDay(bkaoqinForm.getDay());
    	 				
    	 			
    	 				
    	 			   //调用方法
    	 				bkaoqin.add();
    	 			}
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			
    	 		}
    	 		return "inputBkaoqin";
    	 	}
    	 	
    	 	public String list()throws Exception{
    	 		Bkaoqin bkaoqinModel =new Bkaoqin();
    	 		pageList =bkaoqinModel.list(page,size,bkaoqinForm);
    	 		return "listBkaoqin";
    	 	}
    	 	public String del()throws Exception{
    	 		try{
    	 			if(bkaoqinForm!=null){
    	 				bkaoqin.setId(id);
    	 				bkaoqin.delBkaoqin();	
    	 			}
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
    	 	public String editBkaoqin()throws Exception{
    	 		log.info("修改考勤信息");
    	 		try{
    	 			bkaoqin.setId(id);
    	 			bkaoqin.load();
    	 			return "editBkaoqin";
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
    	 	/**
    	 	 * 
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String edit()throws Exception{
    	 		log.info("修改考勤信息");
    	 		try{
    	 			
    	 			if(bkaoqinForm!=null){
    	 			                     
    	 				 //将persinfoForm中的属性值一一对应persinfo的对应属性
    	 				bkaoqin.setId(bkaoqinForm.getId());
    	 				bkaoqin.setBname(bkaoqinForm.getBname());
    	 				bkaoqin.setChuqin(bkaoqinForm.getChuqin());
    	 				bkaoqin.setDay(bkaoqinForm.getDay());
    	 				
    	 				bkaoqin.editBkaoqin();	
    	 			}
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
			public Pager<Bkaoqin> getPageList() {
				return pageList;
			}
			public void setPageList(Pager<Bkaoqin> pageList) {
				this.pageList = pageList;
			}
			
			public Integer getId() {
				return id;
			}
			public void setId(Integer id) {
				this.id = id;
			}
			public Bkaoqin getBkaoqin() {
				return bkaoqin;
			}
			public void setBkaoqin(Bkaoqin bkaoqin) {
				this.bkaoqin = bkaoqin;
			}
			public BkaoqinForm getBkaoqinForm() {
				return bkaoqinForm;
			}
			public void setBkaoqinForm(BkaoqinForm bkaoqinForm) {
				this.bkaoqinForm = bkaoqinForm;
			}
			public static Log getLog() {
				return log;
			}
		
			
    	
}
